﻿using System;

namespace IInject.Registration.Scanning
{
	public class InterfaceNamingScanningRule : NamingScanningRule
	{
		public InterfaceNamingScanningRule(string prefix = "", string suffix = "") : base(prefix, suffix)
		{
		}

		public override MatchingResult IsMatch(Type type)
		{
			var baseType = type.GetInterface(Format(type.Name), true);

			return new MatchingResult
			{
				From = baseType ?? type,
				To = type,
				IsMatch = baseType != null && type.IsPublicClass()
			};
		}
	}
}
